package p270jp.pxv.android.viewholder;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import p014ae.C0180w6;
import p045be.HomePixivisionAdapter;
import p071cd.Functions;
import p165fo.C3114c;
import p187gl.PixivRequest;
import p216hn.DefaultConstructorMarker;
import p270jp.pxv.android.R;
import p270jp.pxv.android.event.ShowPixivisionListEvent;
import p270jp.pxv.android.legacy.constant.PixivisionCategory;
import p270jp.pxv.android.response.PixivResponse;
import p314lg.ViewHomePixivisionBinding;
import p325m0.MutabilityOwnership;
import p350mp.Timber;
import p370ni.InfoType;
import p521th.SolidItemViewHolder;
import p547uh.C6578v3;
import p547uh.View$OnClickListenerC6479k9;
import p569vd.C6830b;
import p569vd.C6831c;
import p645yc.AndroidSchedulers;
import p671zc.CompositeDisposable;
import p671zc.Disposable;
import p677zi.PixivImageLoader;

/* compiled from: HomePixivisionListSolidItemViewHolder.kt */
@SuppressLint({"RxJava2MissingCompositeDisposableClear"})
/* renamed from: jp.pxv.android.viewholder.HomePixivisionListSolidItemViewHolder */
/* loaded from: classes2.dex */
public final class HomePixivisionListSolidItemViewHolder extends SolidItemViewHolder {
    private final HomePixivisionAdapter adapter;
    private final ViewHomePixivisionBinding binding;
    private final CompositeDisposable compositeDisposable;
    private final PixivImageLoader pixivImageLoader;
    private final PixivisionCategory pixivisionCategory;
    private boolean requesting;
    public static final Companion Companion = new Companion(null);
    public static final int $stable = 8;

    /* compiled from: HomePixivisionListSolidItemViewHolder.kt */
    /* renamed from: jp.pxv.android.viewholder.HomePixivisionListSolidItemViewHolder$Companion */
    /* loaded from: classes2.dex */
    public static final class Companion {
        private Companion() {
        }

        public /* synthetic */ Companion(DefaultConstructorMarker eVar) {
            this();
        }

        public final HomePixivisionListSolidItemViewHolder createViewHolder(ViewGroup viewGroup, CompositeDisposable aVar, PixivisionCategory pixivisionCategory, PixivImageLoader aVar2) {
            MutabilityOwnership.m3745m(viewGroup, "parent");
            MutabilityOwnership.m3745m(aVar, "compositeDisposable");
            MutabilityOwnership.m3745m(pixivisionCategory, "pixivisionCategory");
            MutabilityOwnership.m3745m(aVar2, "pixivImageLoader");
            ViewHomePixivisionBinding i9Var = (ViewHomePixivisionBinding) DataBindingUtil.m11370c(LayoutInflater.from(viewGroup.getContext()), R.layout.view_home_pixivision, viewGroup, false);
            MutabilityOwnership.m3746l(i9Var, "binding");
            return new HomePixivisionListSolidItemViewHolder(i9Var, aVar, pixivisionCategory, aVar2, null);
        }
    }

    private HomePixivisionListSolidItemViewHolder(ViewHomePixivisionBinding i9Var, CompositeDisposable aVar, PixivisionCategory pixivisionCategory, PixivImageLoader aVar2) {
        super(i9Var.f2666e);
        this.binding = i9Var;
        this.compositeDisposable = aVar;
        this.pixivisionCategory = pixivisionCategory;
        this.pixivImageLoader = aVar2;
        RecyclerView recyclerView = i9Var.f21696t;
        this.itemView.getContext();
        recyclerView.setLayoutManager(new LinearLayoutManager(0, false));
        HomePixivisionAdapter kVar = new HomePixivisionAdapter(new ArrayList(), aVar2);
        this.adapter = kVar;
        i9Var.f21696t.setAdapter(kVar);
        i9Var.f21694r.setOnClickListener(View$OnClickListenerC6479k9.f27699c);
        if (pixivisionCategory == PixivisionCategory.MANGA) {
            i9Var.f21695s.setVisibility(0);
        }
    }

    public /* synthetic */ HomePixivisionListSolidItemViewHolder(ViewHomePixivisionBinding i9Var, CompositeDisposable aVar, PixivisionCategory pixivisionCategory, PixivImageLoader aVar2, DefaultConstructorMarker eVar) {
        this(i9Var, aVar, pixivisionCategory, aVar2);
    }

    /* renamed from: _init_$lambda-0 */
    public static final void m12314_init_$lambda0(View view) {
        C3114c.m6284b().m6280f(new ShowPixivisionListEvent());
    }

    /* renamed from: e */
    public static /* synthetic */ void m4435e(Throwable th) {
        m12318reload$lambda4(th);
    }

    /* renamed from: i */
    public static /* synthetic */ void m4433i(HomePixivisionListSolidItemViewHolder homePixivisionListSolidItemViewHolder, Disposable bVar) {
        m12315reload$lambda1(homePixivisionListSolidItemViewHolder, bVar);
    }

    private final void reload() {
        if (!this.requesting && this.adapter.mo1393c() <= 0) {
            this.compositeDisposable.mo82c(PixivRequest.m5811f(this.pixivisionCategory).m986o(AndroidSchedulers.m334a()).m992i(new C6830b(this, 22)).m991j(new C6578v3(this, 3)).m984q(new C0180w6(this, 15), C6831c.f29058h, Functions.f5386c, Functions.f5387d));
        }
    }

    /* renamed from: reload$lambda-1 */
    public static final void m12315reload$lambda1(HomePixivisionListSolidItemViewHolder homePixivisionListSolidItemViewHolder, Disposable bVar) {
        MutabilityOwnership.m3745m(homePixivisionListSolidItemViewHolder, "this$0");
        homePixivisionListSolidItemViewHolder.requesting = true;
        homePixivisionListSolidItemViewHolder.binding.f21693q.m4595d(InfoType.LOADING, null);
    }

    /* renamed from: reload$lambda-2 */
    public static final void m12316reload$lambda2(HomePixivisionListSolidItemViewHolder homePixivisionListSolidItemViewHolder) {
        MutabilityOwnership.m3745m(homePixivisionListSolidItemViewHolder, "this$0");
        homePixivisionListSolidItemViewHolder.requesting = false;
        homePixivisionListSolidItemViewHolder.binding.f21693q.m4598a();
    }

    /* renamed from: reload$lambda-3 */
    public static final void m12317reload$lambda3(HomePixivisionListSolidItemViewHolder homePixivisionListSolidItemViewHolder, PixivResponse pixivResponse) {
        MutabilityOwnership.m3745m(homePixivisionListSolidItemViewHolder, "this$0");
        HomePixivisionAdapter kVar = homePixivisionListSolidItemViewHolder.adapter;
        kVar.f4756d = pixivResponse.spotlightArticles;
        kVar.f3606a.m10780b();
    }

    /* renamed from: reload$lambda-4 */
    public static final void m12318reload$lambda4(Throwable th) {
        Timber.f23100a.mo3514p(th);
    }

    @Override // p521th.SolidItemViewHolder
    public void onBindViewHolder(int i) {
        reload();
    }
}
